<!DOCTYPE html>
<html >
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css"  media="all"/>
<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all"/>
<link rel="stylesheet"  href="../../../css/common/loader.css" media="all"/>
<link rel="stylesheet"  href="../../../css/common/openshow.css" media="all"/>
</head>
<body>
<form class="layui-form layui-form-pane" action="" id="saveForm" lay-filter="saveForm">
 <input type="hidden" name="fid" id="fid"/>
 <input type="hidden" name="versionId" />
 <div class="layui-form-item">
    <label class="layui-form-label">apk名称 <span class="layui-red-star">*</span></label>
    <div class="layui-input-inline">
      <input type="text" name="apkName" id="apkName" disabled="disabled"  style="width:250px"  autocomplete="off"  class="layui-input">
     
    </div>
    <button type="button" id="apkUpload" class="layui-btn layui-btn-normal" style="margin-left:55px">上传</button>
  </div>
   <div class="layui-form-item">
    <label class="layui-form-label">版本号 <span class="layui-red-star">*</span></label>
    <div class="layui-input-inline">
      <input type="text" name="versionNum"  style="width:250px" lay-verify="required|max:50"   autocomplete="off"  class="layui-input">
       
    </div>
  </div>
 <div class="layui-form-item">
    <label class="layui-form-label">版本名称 <span class="layui-red-star">*</span></label>
    <div class="layui-input-inline">
      <input type="text" name="versionName" style="width:250px"  lay-verify="required|max:50"   autocomplete="off"  class="layui-input">
    </div>
  </div>
 
   <div class="layui-form-item">
    <label class="layui-form-label">发布状态</label>
    <div class="layui-input-inline">
     <select name="releaseStatus"  style="width:250px"  lay-select-dict="release_status" lay-select-title="NONE" >
    </select>
    </div>
  </div>
   <div class="layui-form-item">
    <label class="layui-form-label">APK类型</label>
    <div class="layui-input-inline">
     <select name="apkType"  style="width:250px"  lay-select-dict="apk_type" lay-select-title="NONE"  >
    </select>
    </div>
  </div>
   <div class="layui-form-item">
    <label class="layui-form-label layui-textarea-label" >升级说明</label>
    <div class="layui-input-block">
      <textarea name="versionDesc" lay-verify="max:200"  class="layui-textarea"></textarea>
    </div>
  </div>

  <!-- 隐藏域 -->
   <div class="layui-form-item" style="display:none;">
    <button class="layui-btn"  lay-submit="" lay-filter="saveSubmit">提交</button>
  </div>
</form>
<script   src="../../../layuiadmin/layui/layui.js"></script>
<script type="text/javascript" src="../../../lib/jQuery-2.2.0.min.js" ></script>
	<script>
	layui.config({
		base :  '../../../layuiadmin/' //静态资源所在路径
	}).extend({
		webplus : 'lib/webplus', //主入口模块
	}).use([ 'form','webplus' ], function() {
		var $ = layui.$, 
		form = layui.form,
	    webplus=layui.webplus,
	    upload=layui.upload;
		
		var apkUpload = upload.render({
			elem: "#apkUpload",
			exts: 'apk',
			data: {
				token: webplus.getToken()
			},
			url: webplus.cxt() + '/buss/apkVersion/uploadApk',
			done: function(res) {
			
				if (res.appCode == '1') {
					$("#fid").val(res.fid);		
					$("#apkName").val(res.apkName);		
				}else{
					layer.msg('Error、タイムオーバー！');
				}
			},
			error: function() {
				layer.msg('Error、タイムオーバー！');
			}
		});
		webplus.initSelect('saveForm',function(){webplus.doAjax('buss/apkVersion/edit',{id:webplus.getUrlType().id},'','0','',function(res){
			if(webplus.isEmpty(res.data)) return false;
			webplus.setFormData("saveForm",res.data);
			
		})});
		
		
		//提交表单
		form.on('submit(saveSubmit)', function(data) {
			var apkName=$("#apkName").val();
			if(webplus.isEmpty(apkName)){
				webplus.alertWarn("请点击上传按钮，进行apk文件上传");
				return false ;
			}
			var paramData = data.field;
			webplus.doAjax('buss/apkVersion/update', paramData,'', '', '1')
			return false;
		});
		
	});
	</script>
</body>
</html>